{% extends "layout.html" %}
{% block content %}
<div class="content-section">
    <form method="POST" action="" enctype="multipart/form-data">
        {{ form.hidden_tag() }}
        <fieldset class="form-group">
            <legend class="border-bottom mb-4">{{ legend }}</legend>
            <!-- 标题字段 -->
            <div class="form-group">
                {{ form.title.label(class="form-control-label") }}
                {% if form.title.errors %}
                    {{ form.title(class="form-control form-control-lg is-invalid") }}
                    <div class="invalid-feedback">
                        {% for error in form.title.errors %}
                            <span>{{ error }}</span>
                        {% endfor %}
                    </div>
                {% else %}
                    {{ form.title(class="form-control form-control-lg") }}
                {% endif %}
            </div>
            <!-- 内容字段（手动输入） -->
            <div class="form-group">
                {{ form.content.label(class="form-control-label") }}
                {% if form.content.errors %}
                    {{ form.content(class="form-control form-control-lg is-invalid") }}
                    <div class="invalid-feedback">
                        {% for error in form.content.errors %}
                            <span>{{ error }}</span>
                        {% endfor %}
                    </div>
                {% else %}
                    {{ form.content(class="form-control form-control-lg", rows=8) }}
                {% endif %}
            </div>
            <!-- 新增：格式选择下拉框 -->
            <div class="form-group mt-3">
                {{ form.content_format.label(class="form-control-label") }}
                {% if form.content_format.errors %}
                    {{ form.content_format(class="form-control form-control-lg is-invalid") }}
                    <div class="invalid-feedback">
                        {% for error in form.content_format.errors %}
                            <span>{{ error }}</span>
                        {% endfor %}
                    </div>
                {% else %}
                    {{ form.content_format(class="form-control form-control-lg") }}
                {% endif %}
            </div>
            <!-- 新增：文件上传框 -->
            <div class="form-group mt-3">
                {{ form.content_file.label() }}
                {{ form.content_file(class="form-control-file") }}
                {% if form.content_file.errors %}
                    {% for error in form.content_file.errors %}
                        <span class="text-danger">{{ error }}</span></br>
                    {% endfor %}
                {% endif %}
                <small class="text-muted">Tip: Uploading a file will override the manual content.</small>
            </div>
        </fieldset>
        <div class="form-group mt-4">
            {{ form.submit(class="btn btn-outline-info") }}
        </div>
    </form>
</div>
{% endblock content %}
